﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using BALayer;

namespace PGBT
{
    public partial class DanhMucBanHang : Form
    {
        private GiaoDich db = null;
        private DataSet dsHoaDon = null;
        private DataSet dsChiTiet = null;

        public DanhMucBanHang()
        {
            InitializeComponent();
        }

        private void DanhMucBanHang_Load(object sender, EventArgs e)
        {
            db = new GiaoDich();
            dsHoaDon = db.DanhSachHoaDon();

            cbMaHoaDon.DataSource = dsHoaDon.Tables[0];
            cbMaHoaDon.DisplayMember = "mahoadon";
        }

        private void cbMaHoaDon_SelectedIndexChanged(object sender, EventArgs e)
        {
            txtTenKH.Text = dsHoaDon.Tables[0].Rows[cbMaHoaDon.SelectedIndex].ItemArray[2].ToString();
            txtNgayBan.Text = dsHoaDon.Tables[0].Rows[cbMaHoaDon.SelectedIndex].ItemArray[3].ToString();

            int mahoadon = Convert.ToInt32(dsHoaDon.Tables[0].Rows[cbMaHoaDon.SelectedIndex].ItemArray[0].ToString());
            dsChiTiet = db.ChiTietHoaDon(mahoadon);
            dgvBanHang.DataSource = dsChiTiet.Tables[0];
            dgvBanHang.AutoResizeColumns();
        }
    }
}
